package com.hoshiicloud.commissioncalculation.feign.hystrix;

import com.hoshiicloud.commissioncalculation.feign.OrderFeignService;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.saleorder.entity.OrderInfo;
import com.hoshiicloud.saleorder.entity.OrderMain;
import com.hoshiicloud.saleorder.param.OrderInfoQueryParam;
import com.hoshiicloud.saleorder.param.OrderMainQueryParam;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author ygd
 * @title: HystrixOrderFeignFallback
 * @projectName hoshiicloud
 * @description: 订单熔断
 * @date 2019/9/5
 */
@Component
public class HystrixOrderFeignFallback implements FallbackFactory<OrderFeignService> {
    @Override
    public OrderFeignService create(Throwable cause) {

        return new OrderFeignService() {
            @Override
            public Response<List<OrderMain>> queryOrderMainList(OrderMainQueryParam param) {
                return Response.failed(cause.getMessage());
            }

            @Override
            public Response<List<OrderInfo>> queryOrderInfoList(OrderInfoQueryParam param) {
                return Response.failed(cause.getMessage());
            }
        };
    }
}
